package listener;

import javax.servlet.annotation.WebListener;
import javax.servlet.http.*;

//@WebListener
public class SessionListener implements HttpSessionListener, HttpSessionAttributeListener {
    @Override
    public void attributeAdded(HttpSessionBindingEvent se) {
        System.out.println("attribute-added-HttpSession: "+se.getName()+" "+se.getValue());
    }

    @Override
    public void attributeRemoved(HttpSessionBindingEvent se) {
        System.out.println("attribute-removed-HttpSession: "+se.getName()+" "+se.getValue());
    }

    @Override
    public void attributeReplaced(HttpSessionBindingEvent se) {
        HttpSession session = se.getSession();
        System.out.println("attribute-replaced-HttpSession: "+se.getName()+" "+se.getValue()+" newValue:"+session.getAttribute(se.getName()));
    }

    @Override
    public void sessionCreated(HttpSessionEvent se) {
        System.out.println("session-created");
    }

    @Override
    public void sessionDestroyed(HttpSessionEvent se) {
        System.out.println("session-destroyed");
    }
}
